<?php

use App\Http\Controllers\Admin\Collection\BrandController;
use App\Http\Controllers\Admin\Collection\CollectionController;
use App\Http\Controllers\Admin\Collection\CollectionFileController;
use App\Http\Controllers\Admin\Server\Tencent\TencentCloudController;
use App\Http\Controllers\Admin\SuperAdmin\ApiController;
use App\Http\Controllers\Admin\SuperAdmin\AuthorityController;
use App\Http\Controllers\Admin\SuperAdmin\MenuController;
use App\Http\Controllers\Admin\User\LoginController;
use App\Http\Controllers\Admin\User\UserController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['prefix' => 'user', 'namespace' => 'User'], function () {
    Route::post('login', [LoginController::class, 'login']); // 登录
    Route::post('captcha', [LoginController::class, 'captcha']); // 验证码

    Route::group(['middleware' => 'auth'], function () {
        Route::post('logout', [LoginController::class, 'logout']); // 退出登录
        Route::get('userInfo', [UserController::class, 'userInfo']); // 用户详情
        Route::post('setSelfInfo', [UserController::class, 'setSelfInfo']); // 设置自身信息
        Route::post('changePassword', [UserController::class, 'changePassword']); // 修改密码
    });
});


// 超级管理员
Route::group(['prefix' => 'superAdmin', 'namespace' => 'SuperAdmin'], function () {
    // 菜单
    Route::group(['prefix' => 'menu', 'middleware' => 'auth'], function () {
        Route::post('updateMenu', [MenuController::class, 'updateMenu']); // 更新菜单
        Route::post('addMenu', [MenuController::class, 'addMenu']); // 添加菜单
        Route::post('deleteMenu', [MenuController::class, 'deleteMenu']); // 删除菜单

        Route::post('addMenuAuthority', [MenuController::class, 'addMenuAuthority']); // 添加角色菜单

        Route::get('getMenu', [MenuController::class, 'getMenu']); // 获取菜单列表
        Route::get('getMenuTree', [MenuController::class, 'getMenuTree']); // 获取用户动态路由
        Route::get('getMenuList', [MenuController::class, 'getMenuList']); // 获取菜单列表
        Route::get('getMenuById', [MenuController::class, 'getMenuById']); // 根据id获取菜单
        Route::get('getMenusByAuthorityId', [MenuController::class, 'getMenusByAuthorityId']); // 获取指定角色menu
    });

    // 角色
    Route::group(['prefix' => 'authority', 'middleware' => 'auth'], function () {
        Route::post('createAuthority', [AuthorityController::class, 'createAuthority']); // 创建角色
        Route::post('updateAuthority', [AuthorityController::class, 'updateAuthority']); // 更新角色
        Route::post('deleteAuthority', [AuthorityController::class, 'deleteAuthority']); // 删除角色
        Route::post('copyAuthority');
        Route::get('authorityList', [AuthorityController::class, 'authorityList']); // 角色列表
    });

    // 接口
    Route::group(['prefix' => 'api', 'middleware' => 'auth'], function () {
        Route::post('createApi', [ApiController::class, 'createApi']); // 创建API
        Route::post('deleteApi', [ApiController::class, 'deleteApi']); // 删除API
        Route::post('updateApi', [ApiController::class, 'updateApi']); // 更新API
        Route::post('updateAuthorityApi', [ApiController::class, 'updateAuthorityApi']); // 更新角色API
        ROute::post('deleteApisByIds', [ApiController::class, 'deleteApisByIds']); // 批量删除

        Route::get('getApiList', [ApiController::class, 'getApiList']); // 获取api列表
        Route::get('allApiList', [ApiController::class, 'allApiList']); // 获取所有api列表
        Route::get('getPolicyPathByAuthorityId', [ApiController::class, 'getPolicyPathByAuthorityId']); // 获取权限列表
        Route::get('detail', [ApiController::class, 'detail']); // api详情
    });

    // 用户
    Route::group(['prefix' => 'user', 'middleware' => 'auth'], function () {
        Route::post('createUser', [UserController::class, 'createUser']); // 创建用户
        Route::post('setUserInfo', [UserController::class, 'setUserInfo']); // 设置用户信息
        Route::post('setUserAuthorities', [UserController::class, 'setUserAuthorities']); // 设置用户角色
        Route::post('resetPassword', [UserController::class, 'resetPassword']); // 重置密码
        Route::post('deleteUser', [UserController::class, 'deleteUser']); // 删除用户
        Route::get('userList', [UserController::class, 'userList']); // 用户列表
    });
});


// 藏品管理
Route::group(['prefix' => 'collection', 'namespace' => 'Collection'], function () {
    // 藏品
    Route::group(['prefix' => 'collection', 'middleware' => 'auth'], function () {
        Route::post('/create', [CollectionController::class, 'create']); // 创建藏品
        Route::post('/delete', [CollectionController::class, 'delete']); // 删除藏品
        Route::post('/update', [CollectionController::class, 'update']); // 更新藏品
        Route::post('/deleteByIds', [CollectionController::class, 'deleteByIds']); // 批量删除藏品
        Route::post('/changeStatus', [CollectionController::class, 'changeStatus']); // 更新状态

        Route::get('/list', [CollectionController::class, 'list']); // 藏品列表
        Route::get('/detail', [CollectionController::class, 'detail']); // 藏品详情
    });

    Route::group(['prefix' => 'collectionFile', 'middleware' => 'auth'], function () {
        Route::get('/list', [CollectionFileController::class, 'list']); // 藏品文件列表
        Route::get('/detail', [CollectionFileController::class, 'detail']); // 藏品文件详情

        Route::post('/create', [CollectionFileController::class, 'create']); // 创建藏品文件
        Route::post('/update', [CollectionFileController::class, 'update']); // 更新藏品文件
        Route::post('/delete', [CollectionFileController::class, 'delete']); // 删除藏品文件
        Route::post('/deleteByIds', [CollectionFileController::class, 'deleteByIds']); // 批量删除藏品文件
    });


    // 品牌
    Route::group(['prefix' => 'brand', 'middleware' => 'auth'], function () {
        Route::get('/listAll', [BrandController::class, 'listAll']); // 全部品牌列表
    });

});

// 三方服务
Route::group(['prefix' => 'server', 'namespace' => 'Server'], function () {
    // 腾讯
    Route::group(['prefix' => 'tencent', 'middleware' => 'auth'], function () {
        Route::post('/uploadFile', [TencentCloudController::class, 'uploadFile']); // 上传

        Route::get('/getUploadToken', [TencentCloudController::class, 'getUploadToken']); // 获取上传token
    });
});
